﻿using System.ComponentModel.Composition;

namespace SetVersionNumber.FileWriters {

	/// <summary>
	/// This file writer updates Assembly Info files written in C#,
	/// and updates both the <c>AssemblyVersion</c> and the <c>AssemblyFileVersion</c>.
	/// </summary>
	[Export(typeof(IFileUpdater))]
	public class AssemblyInfoFileWriter : RegexBaseVersionNumber {

		/// <summary>
		/// Create a new NuGet file writer
		/// </summary>
		public AssemblyInfoFileWriter( )
			: base(@".*Assembly(Version)?Info\.cs$", ASSEMBLY_INFO_REGEX_STRING) {
			// EMPTY
		}


		/// <summary>
		/// The complete assembly info C# regular expression text
		/// </summary>
		/// <remarks>
		/// This regular expression is designed to update either:
		/// <c>[assembly: AssemblyVersion("1.0.0.0")]</c> or
		/// <c>[assembly: AssemblyFileVersion("1.0.0.0")]</c>
		/// </remarks>
		private const string ASSEMBLY_INFO_REGEX_STRING = @"\[\s*assembly\:\s*Assembly(File)?Version\s*\(\s*""(?<"+ VERSION_GROUP_NAME + @">(\d+\.){3}\d+)""\s*\)\s*\s*\]";

	}//class

}//namespace
